//package com.minlia.cloud.autoconfiguration;
//
//import org.springframework.boot.autoconfigure.condition.ConditionalOnMissingBean;
//import org.springframework.context.annotation.Bean;
//import org.springframework.context.annotation.Configuration;
//import org.springframework.context.annotation.Primary;
//import org.springframework.data.redis.cache.RedisCacheManager;
//import org.springframework.data.redis.connection.RedisConnectionFactory;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.serializer.GenericJackson2JsonRedisSerializer;
//import org.springframework.data.redis.serializer.GenericToStringSerializer;
//
//@Configuration
//public class RedisAutoConfiguuration {
//
//    private final RedisTemplate<Object, Object> redisTemplate = new RedisTemplate<Object, Object>();
//
//    @Bean
//    @ConditionalOnMissingBean
//    public RedisTemplate<?, ?> sessionRedisTemplate(RedisConnectionFactory connectionFactory) {
//        final GenericJackson2JsonRedisSerializer jackson2JsonRedisSerializer = new GenericJackson2JsonRedisSerializer();
//        final GenericToStringSerializer<Object> genericToStringSerializer = new GenericToStringSerializer(Object.class);
//        redisTemplate.setConnectionFactory(connectionFactory);
//        redisTemplate.setKeySerializer(genericToStringSerializer);
//        redisTemplate.setValueSerializer(jackson2JsonRedisSerializer);
//        redisTemplate.setDefaultSerializer(jackson2JsonRedisSerializer);
//        redisTemplate.setHashKeySerializer(genericToStringSerializer);
//        redisTemplate.setHashValueSerializer(jackson2JsonRedisSerializer);
//        return redisTemplate;
//    }
//
//    @Bean(name = "redisCacheManager")
//    @Primary
//    @ConditionalOnMissingBean
//    public RedisCacheManager redisCacheManager(RedisTemplate<?, ?> redisTemplate) {
//        RedisCacheManager cacheManager = new RedisCacheManager(redisTemplate);
//        // cacheManager.setDefaultExpiration(300);
//        return cacheManager;
//    }
//}
